package com.qf.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.pojo.Student;
import com.qf.service.StudentService;
import org.omg.CORBA.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 *
 */
@Controller
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;


    @RequestMapping(value = "/all",method = RequestMethod.GET)
    public String selectAll(Model model){
        List<Student> list=studentService.selectAll();
        System.out.println("======="+list);
        model.addAttribute("slist",list);
        return "data";
    }
    @RequestMapping(value = "/all2",method = RequestMethod.GET)
    public ModelAndView selectAll2(ModelAndView mv){
        PageHelper.startPage(1,3);
        List<Student>list=studentService.selectAll();
        PageInfo<Student> pageInfo=new PageInfo<>(list);
        System.out.println(pageInfo);
        mv.addObject("slist",pageInfo);
        mv.setViewName("data");
        return mv;
    }
}
